#include "UniformBuffer.hpp"
#include "Constants.hpp"

void Lumine::UniformBuffer::cleanUp()
{
    uniformBuffers.clear();
    uniformBuffersMemory.clear();
    uniformBuffersMapped.clear();
}

void Lumine::UniformBuffer::Create(vk::DeviceSize size)
{
    uniformBuffers.clear();
    uniformBuffersMapped.clear();
    uniformBuffersMemory.clear();

    for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++)
    {
        vk::DeviceSize bufferSize = sizeof(UniformBufferObject);
        vk::raii::Buffer buffer({});
        vk::raii::DeviceMemory bufferMem({});
        auto usage = vk::BufferUsageFlagBits::eUniformBuffer;
        auto prop = vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent;
        createBuffer(bufferSize, usage, prop, buffer, bufferMem);
        uniformBuffers.emplace_back(std::move(buffer));
        uniformBuffersMemory.emplace_back(std::move(bufferMem));
        uniformBuffersMapped.emplace_back(uniformBuffersMemory[i].mapMemory(0, bufferSize));
    }
}

void Lumine::UniformBuffer::Bind(const vk::raii::CommandBuffer &cmd)
{
}
